const commentService = require('../service/comment.service')
class CommentController {
  async create(ctx, next) {
    const {id} = ctx.user
    const {momentId,content} = ctx.request.body
    const result = await commentService.create(id, momentId, content)
    ctx.body = result
  }
  async replay(ctx, next){
    const {momentId,content} = ctx.request.body;
    const {commentId} = ctx.params
    const {id} = ctx.user
    const result = await commentService.replay(id, momentId, content, commentId)
    ctx.body = result
  }
  async update (ctx, next) {
    const {commentId} = ctx.params
    const {content} = ctx.request.body
    const result = await commentService.update(commentId, content)
    ctx.body = result
  }
  async remove (ctx, next) {
    const {commentId} = ctx.params
    const result = await commentService.remove(commentId)
    ctx.body = result
  }
  async list (ctx, next){
    const {momentId} = ctx.query
    const result = await commentService.getCommentByMomentId(momentId)
    ctx.body = result
  }
}
module.exports = new CommentController()